package com.etheart.music.web.action.index.helper;

import com.etheart.framework.core.dao.QueryService;
import com.etheart.framework.core.fulltextsearch.IndexService;
import com.etheart.framework.core.fulltextsearch.MassIndexerProgressMonitorImpl;
import com.etheart.model.entity.Album;
import com.etheart.model.entity.Singer;
import com.etheart.model.entity.Song;

public class IndexThread extends Thread {
	private IndexService indexService;
	
	public IndexThread(IndexService indexService){
		this.indexService = indexService;
	}
	@Override
	public synchronized void start() {
		// TODO Auto-generated method stub
		super.start();
	}
	
	
	@Override
	public void run() {
		execute(Song.class);
		execute(Album.class);
		execute(Singer.class);
		
	}
	MassIndexerProgressMonitorImpl m;
	private void execute(Class clazz) {
		
			m= new MassIndexerProgressMonitorImpl();
			indexService.index2(clazz,m);
	}
	
	
	public String getMessage() {
		if (m== null) {
			return "监视器为空";
		}
		return m.getMessage();
	}
	
	
}
